-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove some 'not defined' notices in importer code #399
base: master
Are you sure you want to change the base?
Conversation
@@ -168,11 +168,19 @@ function import_file( $file_path, $params ) | |||
|
|||
// first: set the count | |||
$params['total_tx_count'] = 0; | |||
foreach ($config->payments as $payment_spec) { | |||
$params['total_tx_count'] += $this->xpath->query($payment_spec->path)->length; | |||
if (!empty($config->payments)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As empty()
doesn't check for the statement being an array/iterable, I suppose $config->payments
is guaranteed to always be an array if it's not empty?
@@ -315,7 +327,12 @@ protected function filterMatches($payment_node, $filter) { | |||
*/ | |||
protected function import_payment($payment_spec, $payment_node, $stmt_data, $index, $params) { | |||
$config = $this->_plugin_config; | |||
$progress = ((float)$index / (float) $params['total_tx_count']); | |||
$total_tx_count = (float) $params['total_tx_count'] ?? 1.0; | |||
if ($total_tx_count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this condition necessary now that there's a null-coalescing default of 1.0
and an implicit default of 0
due to the type cast to float
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might also use some brackets, too. If I get that right, he type cast will always cause a non-NULL
value be given to the null-coalescing operator, making it rather useless here. Maybe this helps.
$progress = ((float)$index / (float) $params['total_tx_count']); | ||
$total_tx_count = (float) $params['total_tx_count'] ?? 1.0; | ||
if ($total_tx_count) { | ||
$progress = ((float)$index / ((float) $params['total_tx_count'] ?? 0.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if so, this should read $total_tx_count
instead of $params['total_tx_count']
, right?
No description provided.